package com.intpro.demo.Service;

import com.intpro.demo.DAO.HotSpot;
import java.util.List;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.mongodb.core.MongoTemplate;
import org.springframework.data.mongodb.core.query.Criteria;
import org.springframework.data.mongodb.core.query.Query;
import org.springframework.stereotype.Service;

@Service
public class HotSpotService
{

	@Autowired
	private MongoTemplate mongoTemplate;

	public List<HotSpot> getAll()
	{
		Query q1 = new Query();
		return mongoTemplate.find(q1, HotSpot.class);
	}

	public void update(HotSpot h)
	{
		mongoTemplate.save(h);
	}

	public void add(HotSpot h)
	{
		mongoTemplate.insert(h);
	}

	public HotSpot find(String id)
	{
		Query q1 = new Query(Criteria.where("id").is(id));
		return mongoTemplate.findOne(q1, HotSpot.class);
	}
	public void remove(String id)
	{
		Query q1 = new Query(Criteria.where("id").is(id));
		mongoTemplate.remove(q1, HotSpot.class);
	}

}
